package com.chixing.day11_exception;




public class LinkString {
    private Node first;
    private Node last;
    private int size;
    private int modCount;



    public void addLast(String element){
        if(first == null){
            first = new Node( null,element,null);
            last = first;   //first = null -----> first = last
        }else{
            Node oldlast = last;
            last = new Node(oldlast,element,null);
            oldlast.next = last;

        }
        size++;
        modCount++;

    }
    public class Node{

        Node previous;//前一个元素
        String value;//元素本身
        Node next; //后一个元素

        public Node(Node previous, String value, Node next) {
            this.previous = previous;
            this.value = value;
            this.next = next;
        }
    }
    public void show(){
        Node node = first;
        while(node != null){
            System.out.println(node.value);
            node = node.next;
        }
    }

}
